package com.wpzf.ndhc.controller;

import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.core.web.domain.AjaxResult;
import com.wpzf.common.log.annotation.Log;
import com.wpzf.common.log.enums.BusinessType;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.common.security.utils.SecurityUtils;
import com.wpzf.ndhc.domain.*;
import com.wpzf.ndhc.service.WpzfNdhcAppService;
import com.wpzf.ndhc.service.WpzfNdhcShijshService;
import com.wpzf.ndhc.service.WpzfNdhcTbBaseService;
import com.wpzf.ndhc.service.WpzfNdhcXjtbTbBaseService;
import com.wpzf.ndhc.utils.WpzfNdhcExcelUtils;
import com.wpzf.ndhc.utils.WpzfNdhcGdalUtils;
import com.wpzf.system.api.model.LoginUser;
import com.wpzf.zxhc.domain.WpCjDkpw2023DTO;
import com.wpzf.zxhc.utils.MultipleFileUnZip;
import net.lingala.zip4j.exception.ZipException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/wpzfndhcshijsh")
public class WpzfNdhcShijshController {

    @Autowired
    WpzfNdhcShijshService wpzfNdhcShijshServiceImpl;

    @Autowired
    WpzfNdhcXjtbTbBaseService wpzfNdhcXjtbTbBaseService;

    @Autowired
    WpzfNdhcTbBaseService wpzfNdhcTbBaseService;

    @Autowired
    TokenService tokenService;

    @Autowired
    WpzfNdhcAppService wpzfNdhcAppService;

    @Value("${tempath}")
    public String tempath;

    @RequestMapping(value = "/getCityDkShPch", method = RequestMethod.POST)
    public AjaxResult getCityDkShPch(@RequestBody Map<String, Object> param) {
        try {
            String sXzqdm = param.get("xzqdm") + "";
            if (sXzqdm.trim().isEmpty() || sXzqdm.equals("null")) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                param.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            }
            List<Map> list = wpzfNdhcShijshServiceImpl.getCityDkShPch(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getCityDkShInfo", method = RequestMethod.POST)
    public AjaxResult getCityDkShInfo(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = wpzfNdhcShijshServiceImpl.getCityDkShInfo(param);
            int total = list.size();
            int nPageNum = Integer.parseInt(param.get("pageNum") + "");
            int nPageSize = Integer.parseInt(param.get("pageSize") + "");
            List<Map> lstMap = dataPagination(list, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkShInfoByXzq", method = RequestMethod.POST)
    public AjaxResult getDkShInfoByXzq(@RequestBody Map<String, Object> param) {
        try {
            List<Map> list = wpzfNdhcShijshServiceImpl.getDkShInfoByXzq(param);
            int total = list.size();
            int nPageNum = Integer.parseInt(param.get("pageNum") + "");
            int nPageSize = Integer.parseInt(param.get("pageSize") + "");
            List<Map> lstMap = dataPagination(list, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkShInfoByXzqIds", method = RequestMethod.POST)
    public AjaxResult getDkShInfoByXzqIds(@RequestBody Map<String, Object> param) {
        try {
            List<Map> list = wpzfNdhcShijshServiceImpl.getDkShInfoByXzqIds(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getLeftData", method = RequestMethod.POST)
    public AjaxResult getLeftData(@RequestBody Map<String, Object> param) {
        try {
            List<Map> list = wpzfNdhcShijshServiceImpl.getLeftData(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/getDkHcInfo", method = RequestMethod.POST)
    public AjaxResult getDkHcInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("tbbh") + "";
        if (jcbh.indexOf(",") != -1) {
            String dkbh1 = jcbh.split(",")[0];
            parm.put("jcbh", dkbh1.split("-")[0]);
            parm.replace("tbbh", dkbh1.split("-")[0]);
            parm.put("dkbh", jcbh);
        } else {
            parm.put("jcbh", jcbh.split("-")[0]);
            parm.replace("tbbh", jcbh.split("-")[0]);
            parm.put("dkbh", jcbh);
        }
        try {
            //modelMap
            ModelMap modelMap = wpzfNdhcXjtbTbBaseService.getShowImgs(parm);//jcbh-xzqdm-pch
            //地块信息
            WpCjDkxxbxjNdDTO dkxxbxj2023DTO = wpzfNdhcShijshServiceImpl.getDkInfoByDkbh(parm);//dkbh-pch
            //关联地块信息
            List<WpCjDkxxbxjNdDTO> dkxxbxj2023DTOList = wpzfNdhcShijshServiceImpl.getRelationDkInfoByJcbh(parm);//jcbh-pch
            //核查结果
            Map wpCjTbhcjgSj2023 = wpzfNdhcShijshServiceImpl.getCityDkHcJgInfo(parm);//tbbh-pch
            if (wpCjTbhcjgSj2023 == null) {
                wpCjTbhcjgSj2023 = new HashMap();
                wpCjTbhcjgSj2023.put("hcjl", "");
                wpCjTbhcjgSj2023.put("hcsm", "");
            }
            //图斑示意图
            List<WpCjTbjtNdDTO> wpCjTbjt2023DTOS = wpzfNdhcTbBaseService.querytbjtBytbbh(parm);//tbbh-xzqdm-pch
            //图斑信息
            List<WpCjTbxxbxjNdDTO> tbxxbxj2023DTOS = wpzfNdhcShijshServiceImpl.getTbInfoByJcbh(parm);//jcbh-pch

            List<WpCjDkxxbxjNdDTO> dkxxbxjWtg2023DTOS = wpzfNdhcXjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);

            Map<String, Object> map = new HashMap<>();
            map.put("modelMap", modelMap);
            map.put("wpCjDkxxb2023dto", dkxxbxj2023DTO);
            map.put("wpCjDkxxb2023relatedto", dkxxbxj2023DTOList);
            map.put("wpCjTbhcjg2023DTOS", wpCjTbhcjgSj2023);
            map.put("wpCjTbjt2023DTOS", wpCjTbjt2023DTOS);
            map.put("wpCjTbxxb2023DTOS", tbxxbxj2023DTOS);
            map.put("wpCjDkxxbxj2023List", dkxxbxjWtg2023DTOS);
            return AjaxResult.success("获取成功", map);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/addHcjgSj", method = RequestMethod.POST)
    public AjaxResult addHcjgSj(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            Integer nSelCount = wpzfNdhcShijshServiceImpl.selectDkHcJg(parm);
            if (nSelCount > 0) {
                Integer nUp = wpzfNdhcShijshServiceImpl.updateDkHcJg(parm);
            } else {
                Integer nInsertJg = wpzfNdhcShijshServiceImpl.insertDkHcJg(parm);
            }
            /*Integer nDel = wpzfNdhcShijshServiceImpl.deleteDkHcJg(parm);
            Integer nInsertLz = wpzfNdhcShijshServiceImpl.insertOperationFlow(parm);
            String hcjl = parm.get("hcjl") + "";
            if (hcjl.equals("同意")) {
                parm.put("dkzt", 3);
            } else {
                parm.put("dkzt", 4);
            }
            Integer nUpdate = wpzfNdhcShijshServiceImpl.updateDkzt(parm);*/
            List<Map> list = wpzfNdhcShijshServiceImpl.getDkShInfoByXzqIds(parm);
            return AjaxResult.success("添加核查结果成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("添加核查结果失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/returnDkHcXj", method = RequestMethod.POST)
    public AjaxResult returnDkHcXj(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            List<Map> lstMap = objToList(parm.get("dkbh"), Map.class);
            Integer nUpdate = 0;
            for (Map m : lstMap) {
                m.put("hcr", loginUser.getUsername());
                m.put("thyy", parm.get("thyy"));
                Integer nInsertLz = wpzfNdhcShijshServiceImpl.insertOperationFlow(m);
                //String hcjl = parm.get("hcjl") + "";
                //if (hcjl.equals("同意")) {
                //    parm.put("dkzt", 3);
                //} else {
                m.replace("dkzt", 4);
                //}
                nUpdate += wpzfNdhcShijshServiceImpl.updateDkzt(m);
            }
            return AjaxResult.success("退回成功", nUpdate);
        } catch (Exception ex) {
            return AjaxResult.error("退回失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/citySubmit", method = RequestMethod.POST)
    public AjaxResult citySubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            Integer nSubmit = wpzfNdhcShijshServiceImpl.citySubmit(parm);
            return AjaxResult.success("提交成功", nSubmit);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/getProvBackDkInfo", method = RequestMethod.POST)
    public AjaxResult getProvBackDkInfo(@RequestBody Map<String, Object> param) {
        try {
            String sXzqdm = param.get("xzqdm") + "";
            if (sXzqdm.trim().isEmpty() || sXzqdm.equals("null")) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                param.replace("xzqdm", loginUser.getSysUser().getXzqdm() + "");
            }
            List<Map> list = wpzfNdhcShijshServiceImpl.getProvBackDkInfo(param);
            int total = list.size();
            int nPageNum = Integer.parseInt(param.get("pageNum") + "");
            int nPageSize = Integer.parseInt(param.get("pageSize") + "");
            List<Map> lstMap = dataPagination(list, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/getProvBackPch", method = RequestMethod.POST)
    public AjaxResult getProvBackPch(@RequestBody Map<String, Object> param) {
        try {
            String sXzqdm = param.get("xzqdm") + "";
            if (sXzqdm.trim().isEmpty() || sXzqdm.equals("null")) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                param.put("xzqdm", loginUser.getSysUser().getXzqdm() + "");
            }
            List<Map> list = wpzfNdhcShijshServiceImpl.getProvBackPch(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/getDkFlowInfo", method = RequestMethod.POST)
    public AjaxResult getDkFlowInfo(@RequestBody Map<String, Object> param) {
        try {
            List<Map> list = wpzfNdhcShijshServiceImpl.getDkFlowInfo(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getXjZgDkInfo", method = RequestMethod.POST)
    public AjaxResult getXjZgDkInfo(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = wpzfNdhcShijshServiceImpl.getXjZgDkInfo(param);
            int total = list.size();
            int nPageNum = Integer.parseInt(param.get("pageNum") + "");
            int nPageSize = Integer.parseInt(param.get("pageSize") + "");
            List<Map> lstMap = dataPagination(list, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getXjZgDkInfoIds", method = RequestMethod.POST)
    public AjaxResult getXjZgDkInfoIds(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = wpzfNdhcShijshServiceImpl.getXjZgDkInfoIds(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/getXjZgDkPch", method = RequestMethod.POST)
    public AjaxResult getXjZgDkPch(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = wpzfNdhcShijshServiceImpl.getXjZgDkPch(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getXjZgDkLeftData", method = RequestMethod.POST)
    public AjaxResult getXjZgDkLeftData(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = wpzfNdhcShijshServiceImpl.getXjZgDkLeftData(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/getDkHcInfoXjZg", method = RequestMethod.POST)
    public AjaxResult getDkHcInfoXjZg(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("tbbh") + "";
        if (jcbh.indexOf(",") != -1) {
            String dkbh1 = jcbh.split(",")[0];
            parm.put("jcbh", dkbh1.split("-")[0]);
            parm.replace("tbbh", dkbh1.split("-")[0]);
            parm.put("dkbh", jcbh);
        } else {
            parm.put("jcbh", jcbh.split("-")[0]);
            parm.replace("tbbh", jcbh.split("-")[0]);
            parm.put("dkbh", jcbh);
        }
        try {
            //modelMap
            ModelMap modelMap = wpzfNdhcXjtbTbBaseService.getShowImgs(parm);//jcbh-xzqdm-pch
            //地块信息
            WpCjDkxxbxjNdDTO dkxxbxj2023DTO = wpzfNdhcShijshServiceImpl.getDkInfoByDkbh(parm);//dkbh-pch
            //关联地块信息
            List<WpCjDkxxbxjNdDTO> dkxxbxj2023DTOList = wpzfNdhcShijshServiceImpl.getRelationDkInfoByJcbh(parm);//jcbh-pch
            //核查结果
            Map wpCjTbhcjgSj2023 = wpzfNdhcShijshServiceImpl.getDkHcJgInfoXjZg(parm);//tbbh-pch
            if (wpCjTbhcjgSj2023 == null) {
                wpCjTbhcjgSj2023 = new HashMap();
                wpCjTbhcjgSj2023.put("hcjl", "");
                wpCjTbhcjgSj2023.put("hcsm", "");
            }
            //图斑示意图
            List<WpCjTbjtNdDTO> wpCjTbjt2023DTOS = wpzfNdhcTbBaseService.querytbjtBytbbh(parm);//tbbh-xzqdm-pch
            //图斑信息
            List<WpCjTbxxbxjNdDTO> tbxxbxj2023DTOS = wpzfNdhcShijshServiceImpl.getTbInfoByJcbh(parm);//jcbh-pch

            Map<String, Object> map = new HashMap<>();
            map.put("modelMap", modelMap);
            map.put("wpCjDkxxb2023dto", dkxxbxj2023DTO);
            map.put("wpCjDkxxb2023relatedto", dkxxbxj2023DTOList);
            map.put("wpCjTbhcjg2023DTOS", wpCjTbhcjgSj2023);
            map.put("wpCjTbjt2023DTOS", wpCjTbjt2023DTOS);
            map.put("wpCjTbxxb2023DTOS", tbxxbxj2023DTOS);
            return AjaxResult.success("获取成功", map);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/addHcjgSjXjZg", method = RequestMethod.POST)
    public AjaxResult addHcjgSjXjZg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            Integer nSelCount = wpzfNdhcShijshServiceImpl.selectDkHcJg(parm);
            if (nSelCount > 0) {
                Integer nUp = wpzfNdhcShijshServiceImpl.updateDkHcJgXjZg(parm);
            } else {
                Integer nInsertJg = wpzfNdhcShijshServiceImpl.insertDkHcJg(parm);
            }
            /*Integer nDel = wpzfNdhcShijshServiceImpl.deleteDkHcJg(parm);
            Integer nInsertLz = wpzfNdhcShijshServiceImpl.insertOperationFlow(parm);
            String hcjl = parm.get("hcjl") + "";
            if (hcjl.equals("同意")) {
                parm.put("dkzt", 3);
            } else {
                parm.put("dkzt", 4);
            }
            Integer nUpdate = wpzfNdhcShijshServiceImpl.updateDkzt(parm);*/
            List<Map> list = wpzfNdhcShijshServiceImpl.getXjZgDkInfoIds(parm);
            return AjaxResult.success("添加核查结果成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("添加核查结果失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/xjZgSubmit", method = RequestMethod.POST)
    public AjaxResult xjZgSubmit(@RequestBody Map<String, Object> parm) {
        try {
            Integer nSubmit = -1;
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            List<Map> lstMap = objToList(parm.get("dkxx"), Map.class);
            for (Map m : lstMap) {
                m.put("dkzt", "6");
                m.put("hcr", loginUser.getUsername());
                nSubmit += wpzfNdhcShijshServiceImpl.xjZgSubmit(m);
            }
            return AjaxResult.success("提交成功", nSubmit);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    public String method(Object object) {
        String obj = object != null ? object.toString() : "";
        return obj;
    }

    public static <T> List<T> objToList(Object obj, Class<T> cla) {
        List<T> list = new ArrayList<T>();
        if (obj instanceof ArrayList<?>) {
            for (Object o : (List<?>) obj) {
                list.add(cla.cast(o));
            }
            return list;
        }
        return null;
    }

    private List<Map> dataPagination(List<Map> lstData, int nPageNum, int nPageSize) {
        List<Map> lstMap = new ArrayList<>();
        int nStartIdx = nPageNum - 1;
        lstMap = lstData.stream().skip(nStartIdx * nPageSize).limit(nPageSize).collect(Collectors.toList());
        return lstMap;
    }

    //暂存
    @RequestMapping(value = "/saveShiTbjg", method = RequestMethod.POST)
    public AjaxResult saveShiTbjg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            Integer rest = wpzfNdhcShijshServiceImpl.saveShiTbjg(parm);
            return AjaxResult.success("保存 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存 失败", ex.toString());
        }
    }

    //市级地块审核详情
    @RequestMapping(value = "/getShiShTaskInfo", method = RequestMethod.POST)
    public AjaxResult getShiShTaskInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("jcbh") + "";
        parm.put("tbbh", parm.get("dkbh"));
        if (jcbh.indexOf(",") != -1) {
            parm.put("jcbh", jcbh.split("-")[0]);
        }
        try {
            WpCjTbBaseinfosjNdDTO wpcjTbBaseinfosjDTO = new WpCjTbBaseinfosjNdDTO();
            List<WpCjDkpw2023DTO> lists = new ArrayList<>();
            //获取地块信息  dkxxbxj2023DTOS
            WpCjDkxxbxjNdDTO wpcjDkxxb2023DTO = wpzfNdhcShijshServiceImpl.getDkInfoByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjDkxxb2023dto(wpcjDkxxb2023DTO);

            //获取图斑信息 相关图斑全部查出
            List<WpCjTbxxbxjNdDTO> wpCjTbxxb2023DTOS = wpzfNdhcShijshServiceImpl.getTbxxbxjByJcbhList(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbxxb2023DTOS(wpCjTbxxb2023DTOS);


            //其他相关的拆分地块
            List<WpCjDkxxbxjNdDTO> wpCjDkxxb2023relatedto = wpzfNdhcXjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjDkxxb2023relatedto(wpCjDkxxb2023relatedto);


            //获取举证照片
            parm.put("sfzz", "自主提取".equals(wpCjTbxxb2023DTOS.get(0).getGjxfhzztq()) ? "1" : "0");
            WpCjGsinfolyNdDTO gsinfoly = wpzfNdhcXjtbTbBaseService.getGsinfoly(parm);

            wpcjTbBaseinfosjDTO.setWpCjGsinfolyNdDTO(gsinfoly);

            ModelMap modelMap = new ModelMap();
            if ("0".equals(gsinfoly.getInfoly())) {
                modelMap = wpzfNdhcXjtbTbBaseService.getShowImgsnew(parm);
            } else if ("1".equals(gsinfoly.getInfoly())) {
                List<String> list = new ArrayList<>();
                list.add(wpzfNdhcAppService.getInfo(parm));
//                System.out.println(list);
                modelMap.put("data", list);
            }
            wpcjTbBaseinfosjDTO.setModelMap(modelMap);

            //图斑截图
            List<WpCjTbjtNdDTO> wpCjTbjt2023DTOS = wpzfNdhcXjtbTbBaseService.querytbjtBytbbhsheng1(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbjt2023DTOS(wpCjTbjt2023DTOS);

            //获取市级审核信息
            WpCjTbhcjgshijNdDTO tbhcjgshijByDkbh = wpzfNdhcShijshServiceImpl.getTbhcjgshijByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbhcjgshij2023(tbhcjgshijByDkbh);

            return AjaxResult.success("获取成功", wpcjTbBaseinfosjDTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //市级提交到省级
    @RequestMapping(value = "/shiSubmit", method = RequestMethod.POST)
    public AjaxResult shiSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = wpzfNdhcShijshServiceImpl.shiSubmit(parm);
            return AjaxResult.success("市级提交到省级 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("市级提交到省级 失败", ex.toString());
        }
    }


    //省级复审提交到省级
    @RequestMapping(value = "/shiSubmitZG", method = RequestMethod.POST)
    public AjaxResult shiSubmitZG(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = wpzfNdhcShijshServiceImpl.shiSubmitZG(parm);
            return AjaxResult.success("市级提交到省级 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("市级提交到省级 失败", ex.toString());
        }
    }

    //市级退回修改
    @RequestMapping(value = "/shiThxg", method = RequestMethod.POST)
    public AjaxResult shiThxg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = wpzfNdhcShijshServiceImpl.shiThxg(parm);
            return AjaxResult.success("退回修改 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("退回修改 失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/queryShiTask", method = RequestMethod.POST)
    public AjaxResult queryShiTaskByIndex(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = SecurityUtils.getLoginUser();
            String xzqdmjq = loginUser.getSysUser().getXzqdmjq();
            String[] xzqdmjqArray = null;
            if (xzqdmjq != null && !"".equals(xzqdmjq)) {
                xzqdmjqArray = xzqdmjq.split(",");
            }
            parm.put("xzqdmjqArray", xzqdmjqArray);
            List<Integer> lstDkzt = new ArrayList<>();
            String dkzts = parm.get("dkzt") + "";
            if (!dkzts.isEmpty()) {
                for (String zt : dkzts.split(",")) {
                    lstDkzt.add(Integer.parseInt(zt.replace("'", "")));
                }
                parm.put("lstDkzt", lstDkzt);
            }
            List<WpzfNdhcYtbTbInfo> rest = wpzfNdhcShijshServiceImpl.queryShiTaskEX(parm);
            int total = rest.size();
            int nPageNum = Integer.parseInt(parm.get("pageNum") + "");
            int nPageSize = Integer.parseInt(parm.get("pageSize") + "");
            List<WpzfNdhcYtbTbInfo> lstMap = dataPaginationYtbTbInfo(rest, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);

            //List<WpzfNdhcYtbTbInfo> rest = wpzfNdhcShijshServiceImpl.queryShiTask(parm);
            //return AjaxResult.success(" 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error(" 失败", ex.toString());
        }
    }

    private List<WpzfNdhcYtbTbInfo> dataPaginationYtbTbInfo(List<WpzfNdhcYtbTbInfo> lstData, int nPageNum, int nPageSize) {
        List<WpzfNdhcYtbTbInfo> lstMap = new ArrayList<>();
        int nStartIdx = nPageNum - 1;
        lstMap = lstData.stream().skip(nStartIdx * nPageSize).limit(nPageSize).collect(Collectors.toList());
        return lstMap;
    }

    @RequestMapping(value = "/queryShiTaskZG", method = RequestMethod.POST)
    public AjaxResult queryShiTaskZG(@RequestBody Map<String, Object> parm) {
        try {
            //List<WpzfNdhcYtbTbInfo> rest = wpzfNdhcShijshServiceImpl.queryShiTaskZG(parm);
            //return AjaxResult.success(" 成功", rest);
            List<WpzfNdhcYtbTbInfo> rest = wpzfNdhcShijshServiceImpl.queryShiTaskZGEX(parm);
            int total = rest.size();
            int nPageNum = Integer.parseInt(parm.get("pageNum") + "");
            int nPageSize = Integer.parseInt(parm.get("pageSize") + "");
            List<WpzfNdhcYtbTbInfo> lstMap = dataPaginationYtbTbInfo(rest, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error(" 失败", ex.toString());
        }
    }

    //查询是否有地块提交到省级
    @RequestMapping(value = "/queryRelatedk", method = RequestMethod.POST)
    public AjaxResult queryRelatedk(@RequestBody Map<String, Object> parm) {
        //所有相关地块
        List<Map<String, Object>> rest = wpzfNdhcXjtbTbBaseService.queryRelatedk(parm);
        //未提交的地块
        List<String> tbbhs = new ArrayList<String>();
        //已经提交的地块
        List<String> tjtbbhs1 = new ArrayList<String>();
        //图斑已经被拆分  地块没有被提交到市级
        String str = "";
        if (rest != null) {
            if (rest.size() > 0) {
                for (int i = 0; i < rest.size(); i++) {
                    String tbbh = rest.get(i).get("tbbh").toString();
                    String dkzt = rest.get(i).get("dkzt").toString();
                    if (!dkzt.equals("3") || !dkzt.equals("8")) {
                        tbbhs.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    } else {
                        tjtbbhs1.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    }
                }
            }
            if (rest.size() == tbbhs.size() && tjtbbhs1.size() == 0) {
                return AjaxResult.success("获取关联图斑 成功", str);
            } else {
                return AjaxResult.error("获取关联图斑 成功", str);
            }
        }
        return AjaxResult.error("获取关联图斑 失败", -1);
    }

    //市级不通过图斑
    @RequestMapping(value = "/queryShiBtgdk", method = RequestMethod.POST)
    public AjaxResult queryShiBtgdk(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = wpzfNdhcShijshServiceImpl.queryShiBtgdk(parm);
        Integer cnt = wpzfNdhcShijshServiceImpl.queryShiBtgdkCount(parm);
        if (rest != null) {
            return AjaxResult.success("获取关联图斑 成功", rest, cnt);
        } else {
            return AjaxResult.error("获取关联图斑 成功", rest);
        }
    }

    /*导出*/
    @Log(title = "导出", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getExport", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult export(@RequestBody Map<String, Object> parm, HttpServletResponse response) {
        WpzfNdhcExcelUtils excel = new WpzfNdhcExcelUtils();
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        String msg = "";
        String rest = "";
        String category = parm.get("category") + "";
        List<String> Colomnlist = new ArrayList<>();
        try {
            parm.put("username", loginUser.getUsername());

            System.out.println(tempath);
            Colomnlist.clear();
            Colomnlist.add("序号");
            Colomnlist.add("省代码");
            Colomnlist.add("县代码");
            Colomnlist.add("省名称");
            Colomnlist.add("市名称");
            Colomnlist.add("县名称");
            Colomnlist.add("地块编号");
            Colomnlist.add("监测编号");
            Colomnlist.add("核查节点");
            Colomnlist.add("判定类型");
            Colomnlist.add("核查结论");
            Colomnlist.add("核查结果说明");
            Colomnlist.add("违法类型");
            Colomnlist.add("图斑分类");
            Colomnlist.add("具体情形");
            Colomnlist.add("核查说明");
            Colomnlist.add("实际用途");
            Colomnlist.add("判定依据说明");

            List<WpzfNdhcYtbTbInfo> list = wpzfNdhcShijshServiceImpl.queryShiTaskEX(parm);
            rest = excel.exportList(response, category, list, Colomnlist, tempath);
            if (rest.contains("error")) {
                msg = "导出失败";
            } else {
                msg = "导出成功";
            }
            return AjaxResult.success(msg, rest);
        } catch (Exception e) {
            e.printStackTrace();
            msg = "导出失败";
        }
        return AjaxResult.error(msg, -1);
    }


    //todo 年度调整


    //查询批次号
    @RequestMapping(value = "/getPch", method = RequestMethod.POST)
    public AjaxResult getPch(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = wpzfNdhcShijshServiceImpl.getPch(param);
        return AjaxResult.success("查询批次号", rest);
    }

    //查询县
    @RequestMapping(value = "/getXian", method = RequestMethod.POST)
    public AjaxResult getXian(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = wpzfNdhcShijshServiceImpl.getXian(param);
        return AjaxResult.success("查询县", rest);
    }

    //根据用户市权限查询地块列表
    @RequestMapping(value = "/queryDkList", method = RequestMethod.POST)
    public AjaxResult queryDkList(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = wpzfNdhcShijshServiceImpl.queryDkList(param);
        Integer cnt = wpzfNdhcShijshServiceImpl.queryDkListCount(param);
        return AjaxResult.success("查询地块列表", rest, cnt);
    }

    //根据用户省市权限查询图斑信息列表  根据index查询
    @RequestMapping(value = "/queryDkByIndex", method = RequestMethod.POST)
    public AjaxResult queryDkByIndex(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        Map<String, Object> rest = wpzfNdhcShijshServiceImpl.queryDkByIndex(param);
        return AjaxResult.success("查询图斑", rest);
    }

    //年度地块审核详情
    @RequestMapping(value = "/queryDkDetails", method = RequestMethod.POST)
    public AjaxResult queryDkDetails(@RequestBody Map<String, Object> param) {
        Map<String, Object> rest = new HashMap<>();
        try {
            String dkbh = param.get("dkbh") + "";
            String xzqdm = param.get("xzqdm") + "";
            String dkbsm = param.get("dkbsm") + "";
            String tbbsm = param.get("tbbsm") + "";

            //地块信息
            Map<String, Object> dkInfo = wpzfNdhcShijshServiceImpl.queryDkInfoByDkbh(param);

            //批文
            StringBuilder tdgypzwh = new StringBuilder(); //土地供应批准文号
            StringBuilder tdgypwly = new StringBuilder(); //土地供应批准来源
            StringBuilder tdgypzmj = new StringBuilder(); //土地供应批准面积
            StringBuilder tdgypzjg = new StringBuilder(); //土地供应批准机关
            StringBuilder tdgypzrq = new StringBuilder(); //土地供应批准日期
            StringBuilder tdgytdgypwlxejl = new StringBuilder(); //土地供应批准面积
            StringBuilder tdgypwlb = new StringBuilder(); //土地供应批文类别
            StringBuilder tdgypznydmj = new StringBuilder(); //土地供应批准农用地面积
            StringBuilder tdgypzgdmj = new StringBuilder(); //土地供应批准耕地面积
            StringBuilder tdgypzyjjbntmj = new StringBuilder(); //土地供应准基本农田面积
//
            StringBuilder zjggpzwh = new StringBuilder(); //增减挂钩批准文号
            StringBuilder zjggpwly = new StringBuilder(); //增减挂钩批文来源
            StringBuilder zjggpzmj = new StringBuilder(); //增减挂钩批准面积
            StringBuilder zjggpzjg = new StringBuilder(); //增减挂钩批准机关
            StringBuilder zjggpzrq = new StringBuilder(); //增减挂钩批准日期
            StringBuilder zjggtdgypwlxejl = new StringBuilder(); //增减挂批准面积
            StringBuilder zjggpwlb = new StringBuilder(); //增减挂批文类别
            StringBuilder zjggpznydmj = new StringBuilder(); //增减挂批准农用地面积
            StringBuilder zjggpzgdmj = new StringBuilder(); //增减挂批准耕地面积
            StringBuilder zjggpzyjjbntmj = new StringBuilder(); //增减挂批准基本农田面积
//
            StringBuilder gkfqdpzwh = new StringBuilder(); //工矿废弃地批准文号
            StringBuilder gkfqdpwly = new StringBuilder(); //工矿废弃地批文来源
            StringBuilder gkfqdpzmj = new StringBuilder(); //工矿废弃地批准面积
            StringBuilder gkfqdpzjg = new StringBuilder(); //工矿废弃地批准机关
            StringBuilder gkfqdpzrq = new StringBuilder(); //工矿废弃地批准日期
            StringBuilder gkfqdtdgypwlxejl = new StringBuilder(); //工矿废弃地批准面积
            StringBuilder gkfqdpwlb = new StringBuilder(); //工矿废弃地批文类别
            StringBuilder gkfqdpznydmj = new StringBuilder(); //工矿废弃地批准农用地面积
            StringBuilder gkfqdpzgdmj = new StringBuilder(); //工矿废弃地批准耕地面积
            StringBuilder gkfqdpzyjjbntmj = new StringBuilder();//工矿废弃地批准基本农田面积
//
            StringBuilder xxydpzwh = new StringBuilder(); //先行用地批准文号
            StringBuilder xxydpwly = new StringBuilder(); //先行用地批准来源
            StringBuilder xxydpzmj = new StringBuilder(); //先行用地批准面积
            StringBuilder xxydpzjg = new StringBuilder(); //先行用地批准机关
            StringBuilder xxydpzrq = new StringBuilder(); //先行用地批准日期
            StringBuilder xxydtdgypwlxejl = new StringBuilder(); //先行批准面积
            StringBuilder xxydpwlb = new StringBuilder(); //先行批文类别
            StringBuilder xxydpznydmj = new StringBuilder(); //先行批准农用地面积
            StringBuilder xxydpzgdmj = new StringBuilder(); //先行批准耕地面积
            StringBuilder xxydpzyjjbntmj = new StringBuilder(); //
//
            StringBuilder ssnydpzwh = new StringBuilder(); //设施农用地批准文号
            StringBuilder ssnydpwly = new StringBuilder(); //设施农用地批准来源
            StringBuilder ssnydpzmj = new StringBuilder(); //设施农用地批准面积
            StringBuilder ssnydpzjg = new StringBuilder(); //设施农用地批准机关
            StringBuilder ssnydpzrq = new StringBuilder(); //设施农用地批准日期
            StringBuilder ssnydtdgypwlxejl = new StringBuilder(); //设施农用地批准面积
            StringBuilder ssnydpwlb = new StringBuilder(); //设施农用地批文类别
            StringBuilder ssnydpznydmj = new StringBuilder(); //设施农用地批准农用地面积
            StringBuilder ssnydpzgdmj = new StringBuilder(); //设施农用地批准耕地面积
            StringBuilder ssnydpzyjjbntmj = new StringBuilder(); //设施农用地批准基本农田面积
//
            StringBuilder lsydpzwh = new StringBuilder(); //临时用地批准文号
            StringBuilder lsydpwly = new StringBuilder(); //临时用地批准来源
            StringBuilder lsydpzmj = new StringBuilder(); //临时用地批准面积
            StringBuilder lsydpzjg = new StringBuilder(); //临时用地批准机关
            StringBuilder lsydpzrq = new StringBuilder(); //临时用地批准日期
            StringBuilder lsydtdgypwlxejl = new StringBuilder(); //临时用地批准面积
            StringBuilder lsydpwlb = new StringBuilder(); //临时用地批文类别
            StringBuilder lsydpznydmj = new StringBuilder(); //临时用地批准农用地面积
            StringBuilder lsydpzgdmj = new StringBuilder(); //临时用地批准耕地面积
            StringBuilder lsydpzyjjbntmj = new StringBuilder(); //临时用地批准基本农田面积
//
            StringBuilder bdcqzspzwh = new StringBuilder(); //不动产权证书批准文号
            StringBuilder bdcqzspwly = new StringBuilder(); //不动产权证书批准来源
            StringBuilder bdcqzspzmj = new StringBuilder(); //不动产权证书批准面积
            StringBuilder bdcqzspzjg = new StringBuilder(); //不动产权证书批准机关
            StringBuilder bdcqzspzrq = new StringBuilder(); //不动产权证书批准日期
            StringBuilder bdcqzstdgypwlxejl = new StringBuilder(); //不动产权证批准面积
            StringBuilder bdcqzspwlb = new StringBuilder(); //不动产权证批文类别
            StringBuilder bdcqzspznydmj = new StringBuilder(); //不动产权证批准农用地面积
            StringBuilder bdcqzspzgdmj = new StringBuilder(); //不动产权证批准耕地面积
            StringBuilder bdcqzspzyjjbntmj = new StringBuilder(); //不动产权证批准基本农田面积
//
            StringBuilder nydzypzwh = new StringBuilder(); //农用地转用批准文号
            StringBuilder nydzypwly = new StringBuilder(); //农用地转用批文来源
            StringBuilder nydzypzmj = new StringBuilder(); //农用地转用批准面积
            StringBuilder nydzypzjg = new StringBuilder(); //农用地转用批准机关
            StringBuilder nydzypzrq = new StringBuilder(); //农用地转用批准日期
            StringBuilder nydzytdgypwlxejl = new StringBuilder(); //农用地批准面积
            StringBuilder nydzypwlb = new StringBuilder(); //农用地批文类别
            StringBuilder nydzypznydmj = new StringBuilder(); //农用地批准农用地面积
            StringBuilder nydzypzgdmj = new StringBuilder(); //农用地批准耕地面积
            StringBuilder nydzypzyjjbntmj = new StringBuilder(); //农用地批准基本农田面积
//
            StringBuilder qtpzwh = new StringBuilder(); //
            StringBuilder qtpwly = new StringBuilder(); //
            StringBuilder qtpzmj = new StringBuilder(); //
            StringBuilder qtpzjg = new StringBuilder(); //
            StringBuilder qtpzrq = new StringBuilder(); //
            StringBuilder qttdgypwlxejl = new StringBuilder(); //
            StringBuilder qtpwlb = new StringBuilder(); //
            StringBuilder qtpznydmj = new StringBuilder(); //
            StringBuilder qtpzgdmj = new StringBuilder(); //
            StringBuilder qtpzyjjbntmj = new StringBuilder(); //

            List<WpSjsbDkpwjbbxxNdDTO> dkpwList = wpzfNdhcShijshServiceImpl.queryDkpwjbxxByDkbsm(param);
            for (WpSjsbDkpwjbbxxNdDTO wpSjsbDkpwjbbxxNdDTO : dkpwList) {
                List<WpSjsbDkfjjbxxNdDTO> fjInfo = wpzfNdhcShijshServiceImpl.queryDkfjjbxxByPwtbbsm(wpSjsbDkpwjbbxxNdDTO);
                wpSjsbDkpwjbbxxNdDTO.setFjInfo(fjInfo);
            }
            rest.put("dkpwInfo", dkpwList);
            if (dkpwList != null && dkpwList.size() > 0) {
                for (WpSjsbDkpwjbbxxNdDTO wpSjsbDkpwjbbxxNdDTO : dkpwList) {
                    String pzwhlx = wpSjsbDkpwjbbxxNdDTO.getPzwhlx();

                    if ("NYDZY".equals(pzwhlx)) {
                        //农转用专用
                        if (nydzypzwh.length() > 0) {
                            nydzypzwh.append(",");
                        }
                        nydzypzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (nydzypwly.length() > 0) {
                            nydzypwly.append(",");
                        }
                        nydzypwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (nydzypzmj.length() > 0) {
                            nydzypzmj.append(",");
                        }
                        nydzypzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (nydzypzjg.length() > 0) {
                            nydzypzjg.append(",");
                        }
                        nydzypzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (nydzypzrq.length() > 0) {
                            nydzypzrq.append(",");
                        }
                        nydzypzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (nydzytdgypwlxejl.length() > 0) {
                            nydzytdgypwlxejl.append(",");
                        }
                        nydzytdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (nydzypwlb.length() > 0) {
                            nydzypwlb.append(",");
                        }
                        nydzypwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (nydzypznydmj.length() > 0) {
                            nydzypznydmj.append(",");
                        }
                        nydzypznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (nydzypzgdmj.length() > 0) {
                            nydzypzgdmj.append(",");
                        }
                        nydzypzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (nydzypzyjjbntmj.length() > 0) {
                            nydzypzyjjbntmj.append(",");
                        }
                        nydzypzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("ZJJG".equals(pzwhlx)) {
                        //增减挂钩
                        if (zjggpzwh.length() > 0) {
                            zjggpzwh.append(",");
                        }
                        zjggpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (zjggpwly.length() > 0) {
                            zjggpwly.append(",");
                        }
                        zjggpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (zjggpzmj.length() > 0) {
                            zjggpzmj.append(",");
                        }
                        zjggpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (zjggpzjg.length() > 0) {
                            zjggpzjg.append(",");
                        }
                        zjggpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (zjggpzrq.length() > 0) {
                            zjggpzrq.append(",");
                        }
                        zjggpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (zjggtdgypwlxejl.length() > 0) {
                            zjggtdgypwlxejl.append(",");
                        }
                        zjggtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (zjggpwlb.length() > 0) {
                            zjggpwlb.append(",");
                        }
                        zjggpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (zjggpznydmj.length() > 0) {
                            zjggpznydmj.append(",");
                        }
                        zjggpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (zjggpzgdmj.length() > 0) {
                            zjggpzgdmj.append(",");
                        }
                        zjggpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (zjggpzyjjbntmj.length() > 0) {
                            zjggpzyjjbntmj.append(",");
                        }
                        zjggpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("GKFQD".equals(pzwhlx)) {
                        //工矿废弃地复垦建新
                        if (gkfqdpzwh.length() > 0) {
                            gkfqdpzwh.append(",");
                        }
                        gkfqdpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (gkfqdpwly.length() > 0) {
                            gkfqdpwly.append(",");
                        }
                        gkfqdpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (gkfqdpzmj.length() > 0) {
                            gkfqdpzmj.append(",");
                        }
                        gkfqdpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (gkfqdpzjg.length() > 0) {
                            gkfqdpzjg.append(",");
                        }
                        gkfqdpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (gkfqdpzrq.length() > 0) {
                            gkfqdpzrq.append(",");
                        }
                        gkfqdpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (gkfqdtdgypwlxejl.length() > 0) {
                            gkfqdtdgypwlxejl.append(",");
                        }
                        gkfqdtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (gkfqdpwlb.length() > 0) {
                            gkfqdpwlb.append(",");
                        }
                        gkfqdpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (gkfqdpznydmj.length() > 0) {
                            gkfqdpznydmj.append(",");
                        }
                        gkfqdpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (gkfqdpzgdmj.length() > 0) {
                            gkfqdpzgdmj.append(",");
                        }
                        gkfqdpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (gkfqdpzyjjbntmj.length() > 0) {
                            gkfqdpzyjjbntmj.append(",");
                        }
                        gkfqdpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("TDGY".equals(pzwhlx)) {
                        //土地供应
                        if (tdgypzwh.length() > 0) {
                            tdgypzwh.append(",");
                        }
                        tdgypzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (tdgypwly.length() > 0) {
                            tdgypwly.append(",");
                        }
                        tdgypwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (tdgypzmj.length() > 0) {
                            tdgypzmj.append(",");
                        }
                        tdgypzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (tdgypzjg.length() > 0) {
                            tdgypzjg.append(",");
                        }
                        tdgypzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (tdgypzrq.length() > 0) {
                            tdgypzrq.append(",");
                        }
                        tdgypzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (tdgytdgypwlxejl.length() > 0) {
                            tdgytdgypwlxejl.append(",");
                        }
                        tdgytdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (tdgypwlb.length() > 0) {
                            tdgypwlb.append(",");
                        }
                        tdgypwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (tdgypznydmj.length() > 0) {
                            tdgypznydmj.append(",");
                        }
                        tdgypznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (tdgypzgdmj.length() > 0) {
                            tdgypzgdmj.append(",");
                        }
                        tdgypzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (tdgypzyjjbntmj.length() > 0) {
                            tdgypzyjjbntmj.append(",");
                        }
                        tdgypzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("XXYD".equals(pzwhlx)) {
                        //先行用地
                        if (xxydpzwh.length() > 0) {
                            xxydpzwh.append(",");
                        }
                        xxydpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (xxydpwly.length() > 0) {
                            xxydpwly.append(",");
                        }
                        xxydpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (xxydpzmj.length() > 0) {
                            xxydpzmj.append(",");
                        }
                        xxydpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (xxydpzjg.length() > 0) {
                            xxydpzjg.append(",");
                        }
                        xxydpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (xxydpzrq.length() > 0) {
                            xxydpzrq.append(",");
                        }
                        xxydpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (xxydtdgypwlxejl.length() > 0) {
                            xxydtdgypwlxejl.append(",");
                        }
                        xxydtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (xxydpwlb.length() > 0) {
                            xxydpwlb.append(",");
                        }
                        xxydpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (xxydpznydmj.length() > 0) {
                            xxydpznydmj.append(",");
                        }
                        xxydpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (xxydpzgdmj.length() > 0) {
                            xxydpzgdmj.append(",");
                        }
                        xxydpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (xxydpzyjjbntmj.length() > 0) {
                            xxydpzyjjbntmj.append(",");
                        }
                        xxydpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("SSNYD".equals(pzwhlx)) {
                        //设施农用地
                        if (ssnydpzwh.length() > 0) {
                            ssnydpzwh.append(",");
                        }
                        ssnydpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (ssnydpwly.length() > 0) {
                            ssnydpwly.append(",");
                        }
                        ssnydpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (ssnydpzmj.length() > 0) {
                            ssnydpzmj.append(",");
                        }
                        ssnydpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (ssnydpzjg.length() > 0) {
                            ssnydpzjg.append(",");
                        }
                        ssnydpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (ssnydpzrq.length() > 0) {
                            ssnydpzrq.append(",");
                        }
                        ssnydpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (ssnydtdgypwlxejl.length() > 0) {
                            ssnydtdgypwlxejl.append(",");
                        }
                        ssnydtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (ssnydpwlb.length() > 0) {
                            ssnydpwlb.append(",");
                        }
                        ssnydpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (ssnydpznydmj.length() > 0) {
                            ssnydpznydmj.append(",");
                        }
                        ssnydpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (ssnydpzgdmj.length() > 0) {
                            ssnydpzgdmj.append(",");
                        }
                        ssnydpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (ssnydpzyjjbntmj.length() > 0) {
                            ssnydpzyjjbntmj.append(",");
                        }
                        ssnydpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("LSYD".equals(pzwhlx)) {
                        //临时用地
                        if (lsydpzwh.length() > 0) {
                            lsydpzwh.append(",");
                        }
                        lsydpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (lsydpwly.length() > 0) {
                            lsydpwly.append(",");
                        }
                        lsydpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (lsydpzmj.length() > 0) {
                            lsydpzmj.append(",");
                        }
                        lsydpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (lsydpzjg.length() > 0) {
                            lsydpzjg.append(",");
                        }
                        lsydpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (lsydpzrq.length() > 0) {
                            lsydpzrq.append(",");
                        }
                        lsydpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (lsydtdgypwlxejl.length() > 0) {
                            lsydtdgypwlxejl.append(",");
                        }
                        lsydtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (lsydpwlb.length() > 0) {
                            lsydpwlb.append(",");
                        }
                        lsydpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (lsydpznydmj.length() > 0) {
                            lsydpznydmj.append(",");
                        }
                        lsydpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (lsydpzgdmj.length() > 0) {
                            lsydpzgdmj.append(",");
                        }
                        lsydpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (lsydpzyjjbntmj.length() > 0) {
                            lsydpzyjjbntmj.append(",");
                        }
                        lsydpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("BDCQZS".equals(pzwhlx)) {
                        //不动产权证书(含土地使用权证等)
                        if (bdcqzspzwh.length() > 0) {
                            bdcqzspzwh.append(",");
                        }
                        bdcqzspzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (bdcqzspwly.length() > 0) {
                            bdcqzspwly.append(",");
                        }
                        bdcqzspwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (bdcqzspzmj.length() > 0) {
                            bdcqzspzmj.append(",");
                        }
                        bdcqzspzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (bdcqzspzjg.length() > 0) {
                            bdcqzspzjg.append(",");
                        }
                        bdcqzspzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (bdcqzspzrq.length() > 0) {
                            bdcqzspzrq.append(",");
                        }
                        bdcqzspzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (bdcqzstdgypwlxejl.length() > 0) {
                            bdcqzstdgypwlxejl.append(",");
                        }
                        bdcqzstdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (bdcqzspwlb.length() > 0) {
                            bdcqzspwlb.append(",");
                        }
                        bdcqzspwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (bdcqzspznydmj.length() > 0) {
                            bdcqzspznydmj.append(",");
                        }
                        bdcqzspznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (bdcqzspzgdmj.length() > 0) {
                            bdcqzspzgdmj.append(",");
                        }
                        bdcqzspzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (bdcqzspzyjjbntmj.length() > 0) {
                            bdcqzspzyjjbntmj.append(",");
                        }
                        bdcqzspzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("QT".equals(pzwhlx)) {
                        //其他
                        if (qtpzwh.length() > 0) {
                            qtpzwh.append(",");
                        }
                        qtpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (qtpwly.length() > 0) {
                            qtpwly.append(",");
                        }
                        qtpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (qtpzmj.length() > 0) {
                            qtpzmj.append(",");
                        }
                        qtpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (qtpzjg.length() > 0) {
                            qtpzjg.append(",");
                        }
                        qtpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (qtpzrq.length() > 0) {
                            qtpzrq.append(",");
                        }
                        qtpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (qttdgypwlxejl.length() > 0) {
                            qttdgypwlxejl.append(",");
                        }
                        qttdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (qtpwlb.length() > 0) {
                            qtpwlb.append(",");
                        }
                        qtpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (qtpznydmj.length() > 0) {
                            qtpznydmj.append(",");
                        }
                        qtpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (qtpzgdmj.length() > 0) {
                            qtpzgdmj.append(",");
                        }
                        qtpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (qtpzyjjbntmj.length() > 0) {
                            qtpzyjjbntmj.append(",");
                        }
                        qtpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    }
                }
                dkInfo.put("pwCount", dkpwList.size());
            }


            dkInfo.put("pwCount", dkpwList != null && dkpwList.size() > 0 ? dkpwList.size() : 0);
            dkInfo.put("tdgypzwh", tdgypzwh.toString());
            dkInfo.put("tdgypwly", tdgypwly.toString());
            dkInfo.put("tdgypzmj", tdgypzmj.toString());
            dkInfo.put("tdgypzjg", tdgypzjg.toString());
            dkInfo.put("tdgypzrq", tdgypzrq.toString());
            dkInfo.put("tdgytdgypwlxejl", tdgytdgypwlxejl.toString());
            dkInfo.put("tdgypznydmj", tdgypznydmj.toString());
            dkInfo.put("tdgypzgdmj", tdgypzgdmj.toString());
            dkInfo.put("tdgypzyjjbntmj", tdgypzyjjbntmj.toString());
            dkInfo.put("zjggpzwh", zjggpzwh.toString());
            dkInfo.put("zjggpwly", zjggpwly.toString());
            dkInfo.put("zjggpzmj", zjggpzmj.toString());
            dkInfo.put("zjggpzjg", zjggpzjg.toString());
            dkInfo.put("zjggpzrq", zjggpzrq.toString());
            dkInfo.put("zjggtdgypwlxejl", zjggtdgypwlxejl.toString());
            dkInfo.put("zjggpwlb", zjggpwlb.toString());
            dkInfo.put("zjggpznydmj", zjggpznydmj.toString());
            dkInfo.put("zjggpzgdmj", zjggpzgdmj.toString());
            dkInfo.put("zjggpzyjjbntmj", zjggpzyjjbntmj.toString());
            dkInfo.put("gkfqdpzwh", gkfqdpzwh.toString());
            dkInfo.put("gkfqdpwly", gkfqdpwly.toString());
            dkInfo.put("gkfqdpzmj", gkfqdpzmj.toString());
            dkInfo.put("gkfqdpzjg", gkfqdpzjg.toString());
            dkInfo.put("gkfqdpzrq", gkfqdpzrq.toString());
            dkInfo.put("gkfqdtdgypwlxejl", gkfqdtdgypwlxejl.toString());
            dkInfo.put("gkfqdpwlb", gkfqdpwlb.toString());
            dkInfo.put("gkfqdpznydmj", gkfqdpznydmj.toString());
            dkInfo.put("gkfqdpzgdmj", gkfqdpzgdmj.toString());
            dkInfo.put("gkfqdpzyjjbntmj", gkfqdpzyjjbntmj.toString());
            dkInfo.put("xxydpzwh", xxydpzwh.toString());
            dkInfo.put("xxydpwly", xxydpwly.toString());
            dkInfo.put("xxydpzmj", xxydpzmj.toString());
            dkInfo.put("xxydpzjg", xxydpzjg.toString());
            dkInfo.put("xxydpzrq", xxydpzrq.toString());
            dkInfo.put("xxydtdgypwlxejl", xxydtdgypwlxejl.toString());
            dkInfo.put("xxydpwlb", xxydpwlb.toString());
            dkInfo.put("xxydpznydmj", xxydpznydmj.toString());
            dkInfo.put("xxydpzgdmj", xxydpzgdmj.toString());
            dkInfo.put("xxydpzyjjbntmj", xxydpzyjjbntmj.toString());
            dkInfo.put("ssnydpzwh", ssnydpzwh.toString());
            dkInfo.put("ssnydpwly", ssnydpwly.toString());
            dkInfo.put("ssnydpzmj", ssnydpzmj.toString());
            dkInfo.put("ssnydpzjg", ssnydpzjg.toString());
            dkInfo.put("ssnydpzrq", ssnydpzrq.toString());
            dkInfo.put("ssnydtdgypwlxejl", ssnydtdgypwlxejl.toString());
            dkInfo.put("ssnydpwlb", ssnydpwlb.toString());
            dkInfo.put("ssnydpznydmj", ssnydpznydmj.toString());
            dkInfo.put("ssnydpzgdmj", ssnydpzgdmj.toString());
            dkInfo.put("ssnydpzyjjbntmj", ssnydpzyjjbntmj.toString());
            dkInfo.put("lsydpzwh", lsydpzwh.toString());
            dkInfo.put("lsydpwly", lsydpwly.toString());
            dkInfo.put("lsydpzmj", lsydpzmj.toString());
            dkInfo.put("lsydpzjg", lsydpzjg.toString());
            dkInfo.put("lsydpzrq", lsydpzrq.toString());
            dkInfo.put("lsydtdgypwlxejl", lsydtdgypwlxejl.toString());
            dkInfo.put("lsydpwlb", lsydpwlb.toString());
            dkInfo.put("lsydpznydmj", lsydpznydmj.toString());
            dkInfo.put("lsydpzgdmj", lsydpzgdmj.toString());
            dkInfo.put("lsydpzyjjbntmj", lsydpzyjjbntmj.toString());
            dkInfo.put("bdcqzspzwh", bdcqzspzwh.toString());
            dkInfo.put("bdcqzspwly", bdcqzspwly.toString());
            dkInfo.put("bdcqzspzmj", bdcqzspzmj.toString());
            dkInfo.put("bdcqzspzjg", bdcqzspzjg.toString());
            dkInfo.put("bdcqzspzrq", bdcqzspzrq.toString());
            dkInfo.put("bdcqzstdgypwlxejl", bdcqzstdgypwlxejl.toString());
            dkInfo.put("bdcqzspwlb", bdcqzspwlb.toString());
            dkInfo.put("bdcqzspznydmj", bdcqzspznydmj.toString());
            dkInfo.put("bdcqzspzgdmj", bdcqzspzgdmj.toString());
            dkInfo.put("bdcqzspzyjjbntmj", bdcqzspzyjjbntmj.toString());
            dkInfo.put("nydzypzwh", nydzypzwh.toString());
            dkInfo.put("nydzypwly", nydzypwly.toString());
            dkInfo.put("nydzypzmj", nydzypzmj.toString());
            dkInfo.put("nydzypzjg", nydzypzjg.toString());
            dkInfo.put("nydzypzrq", nydzypzrq.toString());
            dkInfo.put("nydzytdgypwlxejl", nydzytdgypwlxejl.toString());
            dkInfo.put("nydzypwlb", nydzypwlb.toString());
            dkInfo.put("nydzypznydmj", nydzypznydmj.toString());
            dkInfo.put("nydzypzgdmj", nydzypzgdmj.toString());
            dkInfo.put("nydzypzyjjbntmj", nydzypzyjjbntmj.toString());
            dkInfo.put("qtpzwh", qtpzwh.toString());
            dkInfo.put("qtpwly", qtpwly.toString());
            dkInfo.put("qtpzmj", qtpzmj.toString());
            dkInfo.put("qtpzjg", qtpzjg.toString());
            dkInfo.put("qtpzrq", qtpzrq.toString());
            dkInfo.put("qttdgypwlxejl", qttdgypwlxejl.toString());
            dkInfo.put("qtpwlb", qtpwlb.toString());
            dkInfo.put("qtpznydmj", qtpznydmj.toString());
            dkInfo.put("qtpzgdmj", qtpzgdmj.toString());
            dkInfo.put("qtpzyjjbntmj", qtpzyjjbntmj.toString());

            rest.put("dkInfo", dkInfo);

            //核查附件
            List<WpSjHcfjNdDTO> wpSjHcfjNdDTOList = wpzfNdhcShijshServiceImpl.querySjHcfjByDkbsm(param);
            rest.put("hcfj", wpSjHcfjNdDTOList);

            //结果
            Map<String, Object> resultInfo = wpzfNdhcShijshServiceImpl.queryDkshjgShijiByDkbh(param);
            rest.put("resultInfo", resultInfo);

            //流转
            List<Map<String, Object>> lzInfo = wpzfNdhcShijshServiceImpl.queryLzByDkbh(param);
            rest.put("lzInfo", lzInfo);

            //相关地块信息
            List<Map<String, Object>> relevantDk = wpzfNdhcShijshServiceImpl.queryRelevantDkByDkbh(param);
            rest.put("relevantDk", relevantDk);

            //图斑信息
            Map<String, Object> tbInfo = wpzfNdhcShijshServiceImpl.queryTbInfo(param);
            rest.put("tbInfo", tbInfo);

            //举证照片
//            ModelMap modelMap = WpzfNdhcTbBaseInfoController.getShowImgs(param);
//            rest.put("modelMap", modelMap);

            //附件
            List<WpSjsbDkfjjbxxNdDTO> dkfjjbxxInfo = wpzfNdhcShijshServiceImpl.queryDkfjjbxxByDkbsm(param);
            rest.put("dkfjjbxxInfo", dkfjjbxxInfo);

        } catch (Exception e) {
            System.err.println(e.getMessage());
            return AjaxResult.error("查询地块详情失败");
        }
        return AjaxResult.success("查询地块详情", rest);
    }


    //导出地块列表
    @RequestMapping(value = "/exportDkList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportDkList(@RequestBody Map<String, Object> param, HttpServletResponse response) {
        String rest = "";
        String msg = "";
        WpzfNdhcExcelUtils excel = new WpzfNdhcExcelUtils();
        List<String> Colomnlist = new ArrayList<>();
        Colomnlist.clear();
        Colomnlist.add("序号");
        Colomnlist.add("地块标识码");
        Colomnlist.add("图斑标识码");
        Colomnlist.add("县级行政区代码");
        Colomnlist.add("县级行政区名称");
        Colomnlist.add("地块编号");
        Colomnlist.add("地块面积");
        Colomnlist.add("地块名称");
        Colomnlist.add("地块面积");
        Colomnlist.add("地块中心点X坐标");
        Colomnlist.add("地块中心点Y坐标");
        Colomnlist.add("备注信息");
        Colomnlist.add("子地块范围");
        Colomnlist.add("扩展信息");
        Colomnlist.add("在变更调查中是否按建设用地变更");
        Colomnlist.add("是否违法");
        Colomnlist.add("耕地面积");
        Colomnlist.add("其他农用地面积");
        Colomnlist.add("建设用地面积");
        Colomnlist.add("未利用地面积");


        String operName = SecurityUtils.getUsername();
        param.put("username", operName);
        //获取地块列表
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> list = wpzfNdhcShijshServiceImpl.queryDkList(param);
        rest = excel.exportDkList(response, "地块列表", list, Colomnlist, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            msg = "导出成功";
        }
        return AjaxResult.success(msg, rest);
    }


    MultipleFileUnZip multipleFileUnZip = new MultipleFileUnZip();

    //导出矢量数据
    @RequestMapping(value = "/exportDkShpList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportDkShpList(@RequestBody Map<String, Object> param, HttpServletResponse response) throws ZipException {
        String rest = "";
        String msg = "";
        WpzfNdhcGdalUtils gdalUtils = new WpzfNdhcGdalUtils();
        String operName = SecurityUtils.getUsername();
        param.put("username", operName);
        //获取图斑列表
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> list = wpzfNdhcShijshServiceImpl.queryDkList(param);
        rest = gdalUtils.exportDkList(response, list, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            List<String> arr = new ArrayList<>();
            arr.add(tempath + "\\" + rest);  //shp
            String zippath = tempath + "\\" + rest.replace("shp", "zip");
            //生成了shp
            String str = tempath + "\\" + rest.replace("shp", "prj");
            File file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }

            str = tempath + "\\" + rest.replace("shp", "dbf");
            file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }
            str = tempath + "\\" + rest.replace("shp", "shx");
            file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }
            rest = multipleFileUnZip.fileZip(zippath, arr);
            if (rest == "") {
                File file1 = new File(zippath);
                rest = file1.getName();
                msg = "导出成功";
            } else {
                msg = "导出失败";
            }
        }
        return AjaxResult.success(msg, rest);
    }

    //保存结果 有相同的更新，没有添加
    @RequestMapping(value = "/saveShiDkshjg", method = RequestMethod.POST)
    public AjaxResult saveShiDkshjg(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.put("shr", loginUser.getUsername());
            Integer rest = wpzfNdhcShijshServiceImpl.saveShiDkshjg(param);
            return AjaxResult.success("保存 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存 失败", ex.toString());
        }
    }

    //保存并提交结果 有相同的更新，没有添加 dkzt默认值为2（市级） 提交后改为3（省级） 记录流转信息
    @RequestMapping(value = "/submitShiDkshjg", method = RequestMethod.POST)
    public AjaxResult submitShiDkshjg(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.put("shr", loginUser.getUsername());
            param.put("username", loginUser.getUsername());
            param.put("nickname", loginUser.getSysUser().getNickName());
            Integer rest = wpzfNdhcShijshServiceImpl.submitShiDkshjg(param);
            return AjaxResult.success("市级提交到省级 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("市级提交到省级 失败", ex.toString());
        }
    }


}
